home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Technology Seed / Jan. '98 ATS.toast / QuickTime™ 3.0b11 / QTPublicInterfaces / CIncludes / Controls.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-12  |  26.3 KB  |  815 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Controls.h
  3.  
  4.      Contains:    Control Manager interfaces
  5.  
  6.      Version:    Technology:    MacOS 7.x
  7.                  Release:    QuickTime 3.0 Beta
  8.  
  9.      Copyright:    © 1985-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __CONTROLS__
  19. #define __CONTROLS__
  20.  
  21. #ifndef __MACTYPES__
  22. #include <MacTypes.h>
  23. #endif
  24. #ifndef __QUICKDRAW__
  25. #include <Quickdraw.h>
  26. #endif
  27. #ifndef __MENUS__
  28. #include <Menus.h>
  29. #endif
  30. #if !TARGET_OS_MAC
  31. #ifndef __EVENTS__
  32. #include <Events.h>
  33. #endif
  34. #endif  /*  !TARGET_OS_MAC */
  35.  
  36.  
  37.  
  38. #if PRAGMA_ONCE
  39. #pragma once
  40. #endif
  41.  
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45.  
  46. #if PRAGMA_IMPORT
  47. #pragma import on
  48. #endif
  49.  
  50. #if PRAGMA_STRUCT_ALIGN
  51.     #pragma options align=mac68k
  52. #elif PRAGMA_STRUCT_PACKPUSH
  53.     #pragma pack(push, 2)
  54. #elif PRAGMA_STRUCT_PACK
  55.     #pragma pack(2)
  56. #endif
  57.  
  58. /*
  59.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  60.       • Resource types
  61.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  62. */
  63.  
  64. enum {
  65.     kControlDefProcType            = FOUR_CHAR_CODE('CDEF'),
  66.     kControlTemplateResourceType = FOUR_CHAR_CODE('CNTL'),
  67.     kControlColorTableResourceType = FOUR_CHAR_CODE('cctb'),
  68.     kControlDefProcResourceType    = FOUR_CHAR_CODE('CDEF')
  69. };
  70.  
  71. /*
  72.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  73.       • Format of a 'CNTL' resource
  74.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  75. */
  76.  
  77.  
  78. struct ControlTemplate {
  79.     Rect                             controlRect;
  80.     SInt16                             controlValue;
  81.     Boolean                         controlVisible;
  82.     UInt8                             fill;
  83.     SInt16                             controlMaximum;
  84.     SInt16                             controlMinimum;
  85.     SInt16                             controlDefProcID;
  86.     SInt32                             controlReference;
  87.     Str255                             controlTitle;
  88. };
  89. typedef struct ControlTemplate            ControlTemplate;
  90. typedef ControlTemplate *                ControlTemplatePtr;
  91. typedef ControlTemplatePtr *            ControlTemplateHandle;
  92. /*
  93.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  94.    • CONTROL DEFINITION ID'S
  95.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  96. */
  97.  
  98. /* Standard System 7 procID's*/
  99.  
  100.  
  101. enum {
  102.     pushButProc                    = 0,
  103.     checkBoxProc                = 1,
  104.     radioButProc                = 2,
  105.     scrollBarProc                = 16,
  106.     popupMenuProc                = 1008
  107. };
  108.  
  109. /*
  110.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  111.    • VARIANT CODES
  112.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  113. */
  114.  
  115. typedef SInt16                             ControlVariant;
  116.  
  117. enum {
  118.     kControlNoVariant            = 0,                            /* No variant*/
  119.     kControlUsesOwningWindowsFontVariant = 1 << 3                /* Control uses owning windows font to display text*/
  120. };
  121.  
  122. /*
  123.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  124.    • CONTROL PART CODES
  125.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  126. */
  127. typedef SInt16                             ControlPartCode;
  128.  
  129. enum {
  130.     kControlNoPart                = 0,
  131.     kControlLabelPart            = 1,
  132.     kControlMenuPart            = 2,
  133.     kControlTrianglePart        = 4,
  134.     kControlButtonPart            = 10,
  135.     kControlCheckBoxPart        = 11,
  136.     kControlRadioButtonPart        = 11,
  137.     kControlUpButtonPart        = 20,
  138.     kControlDownButtonPart        = 21,
  139.     kControlPageUpPart            = 22,
  140.     kControlPageDownPart        = 23,
  141.     kControlIndicatorPart        = 129,
  142.     kControlDisabledPart        = 254,
  143.     kControlInactivePart        = 255
  144. };
  145.  
  146. /*
  147.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  148.    • CHECK BOX VALUES
  149.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  150. */
  151.  
  152.  
  153. enum {
  154.     kControlCheckBoxUncheckedValue = 0,
  155.     kControlCheckBoxCheckedValue = 1,
  156.     kControlCheckBoxMixedValue    = 2
  157. };
  158.  
  159. /*
  160.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  161.    • RADIO BUTTON VALUES
  162.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  163. */
  164.  
  165.  
  166. enum {
  167.     kControlRadioButtonUncheckedValue = 0,
  168.     kControlRadioButtonCheckedValue = 1,
  169.     kControlRadioButtonMixedValue = 2
  170. };
  171.  
  172. /*
  173.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  174.    
  175.    • CONTROL POP-UP MENU CONSTANTS
  176.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  177. */
  178.  
  179. /* Variant codes for the System 7 pop-up menu*/
  180.  
  181. enum {
  182.     popupFixedWidth                = 1 << 0,
  183.     popupVariableWidth            = 1 << 1,
  184.     popupUseAddResMenu            = 1 << 2,
  185.     popupUseWFont                = 1 << 3
  186. };
  187.  
  188. /* Menu label styles for the System 7 pop-up menu */
  189.  
  190. enum {
  191.     popupTitleBold                = 1 << 8,
  192.     popupTitleItalic            = 1 << 9,
  193.     popupTitleUnderline            = 1 << 10,
  194.     popupTitleOutline            = 1 << 11,
  195.     popupTitleShadow            = 1 << 12,
  196.     popupTitleCondense            = 1 << 13,
  197.     popupTitleExtend            = 1 << 14,
  198.     popupTitleNoStyle            = 1 << 15
  199. };
  200.  
  201. /* Menu label justifications for the System 7 pop-up menu*/
  202.  
  203. enum {
  204.     popupTitleLeftJust            = 0x00000000,
  205.     popupTitleCenterJust        = 0x00000001,
  206.     popupTitleRightJust            = 0x000000FF
  207. };
  208.  
  209. /*
  210.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  211.    • CONTROL DRAGGRAYRGN CONSTANTS
  212.      For DragGrayRgnUPP used in TrackControl() 
  213.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  214. */
  215.  
  216.  
  217. enum {
  218.     noConstraint                = kNoConstraint,
  219.     hAxisOnly                    = 1,
  220.     vAxisOnly                    = 2
  221. };
  222.  
  223. /*
  224.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  225.    • CONTROL COLOR TABLE PART CODES
  226.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  227. */
  228.  
  229.  
  230. enum {
  231.     cFrameColor                    = 0,
  232.     cBodyColor                    = 1,
  233.     cTextColor                    = 2,
  234.     cThumbColor                    = 3,
  235.     kNumberCtlCTabEntries        = 4
  236. };
  237.  
  238. /*
  239.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  240.    • NON-MAC COMPATIBILITY CODES
  241.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  242. */
  243.  
  244. #if !TARGET_OS_MAC
  245. typedef UInt32                             ControlNotification;
  246.  
  247. enum {
  248.     controlNotifyNothing        = FOUR_CHAR_CODE('nada'),        /* No (null) notification*/
  249.     controlNotifyClick            = FOUR_CHAR_CODE('clik'),        /* Control was clicked*/
  250.     controlNotifyFocus            = FOUR_CHAR_CODE('focu'),        /* Control got keyboard focus*/
  251.     controlNotifyKey            = FOUR_CHAR_CODE('key ')        /* Control got a keypress*/
  252. };
  253.  
  254. typedef UInt32                             ControlCapabilities;
  255.  
  256. enum {
  257.     kControlCanAutoInvalidate    = 1L << 0                        /* Control component automatically invalidates areas left behind after hide/move operation.*/
  258. };
  259.  
  260. /* procID's for our added "controls"*/
  261.  
  262. enum {
  263.     staticTextProc                = 256,                            /* static text*/
  264.     editTextProc                = 272,                            /* editable text*/
  265.     iconProc                    = 288,                            /* icon*/
  266.     userItemProc                = 304,                            /* user drawn item*/
  267.     pictItemProc                = 320                            /* pict*/
  268. };
  269.  
  270. #endif  /*  !TARGET_OS_MAC */
  271.  
  272. /*
  273.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  274.    • CONTROLHANDLE
  275.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  276. */
  277.  
  278. typedef struct ControlRecord             ControlRecord;
  279. typedef ControlRecord *                    ControlPtr;
  280. typedef ControlPtr *                    ControlHandle;
  281. /* ControlRef is obsolete. Use ControlHandle. */
  282. typedef ControlHandle                     ControlRef;
  283. /*
  284.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  285.    • CONTROL ACTIONPROC POINTER
  286.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  287. */
  288. typedef CALLBACK_API( void , ControlActionProcPtr )(ControlHandle theControl, ControlPartCode partCode);
  289. typedef STACK_UPP_TYPE(ControlActionProcPtr)                     ControlActionUPP;
  290. /*
  291.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  292.    • CONTROL COLOR TABLE
  293.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  294. */
  295.  
  296. struct CtlCTab {
  297.     SInt32                             ccSeed;
  298.     SInt16                             ccRider;
  299.     SInt16                             ctSize;
  300.     ColorSpec                         ctTable[4];
  301. };
  302. typedef struct CtlCTab                    CtlCTab;
  303.  
  304. typedef CtlCTab *                        CCTabPtr;
  305. typedef CCTabPtr *                        CCTabHandle;
  306. /*
  307.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  308.    • CONTROL RECORD
  309.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  310. */
  311.  
  312. struct ControlRecord {
  313.     ControlHandle                     nextControl;
  314.     WindowPtr                         contrlOwner;
  315.     Rect                             contrlRect;
  316.     UInt8                             contrlVis;
  317.     UInt8                             contrlHilite;
  318.     SInt16                             contrlValue;
  319.     SInt16                             contrlMin;
  320.     SInt16                             contrlMax;
  321.     Handle                             contrlDefProc;
  322.     Handle                             contrlData;
  323.     ControlActionUPP                 contrlAction;
  324.     SInt32                             contrlRfCon;
  325.     Str255                             contrlTitle;
  326. };
  327.  
  328. /*
  329.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  330.    • AUXILLARY CONTROL RECORD STRUCTURE
  331.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  332. */
  333.  
  334. struct AuxCtlRec {
  335.     Handle                             acNext;
  336.     ControlHandle                     acOwner;
  337.     CCTabHandle                     acCTable;
  338.     SInt16                             acFlags;
  339.     SInt32                             acReserved;
  340.     SInt32                             acRefCon;
  341. };
  342. typedef struct AuxCtlRec                AuxCtlRec;
  343.  
  344. typedef AuxCtlRec *                        AuxCtlPtr;
  345. typedef AuxCtlPtr *                        AuxCtlHandle;
  346. /*
  347.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  348.    • POP-UP MENU PRIVATE DATA STRUCTURE
  349.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  350. */
  351.  
  352. struct PopupPrivateData {
  353.     MenuHandle                         mHandle;
  354.     SInt16                             mID;
  355. };
  356. typedef struct PopupPrivateData            PopupPrivateData;
  357. typedef PopupPrivateData *                PopupPrivateDataPtr;
  358. typedef PopupPrivateDataPtr *            PopupPrivateDataHandle;
  359. /*
  360.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  361.    • CONTROL ACTION PROC UPP'S
  362.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  363. */
  364.  
  365.  
  366. enum { uppControlActionProcInfo = 0x000002C0 };                 /* pascal no_return_value Func(4_bytes, 2_bytes) */
  367. #define NewControlActionProc(userRoutine)                         (ControlActionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppControlActionProcInfo, GetCurrentArchitecture())
  368. #define CallControlActionProc(userRoutine, theControl, partCode)  CALL_TWO_PARAMETER_UPP((userRoutine), uppControlActionProcInfo, (theControl), (partCode))
  369. /*
  370.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  371.       
  372.    • CONTROL CREATION / DELETION API'S
  373.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  374. */
  375. EXTERN_API( ControlHandle )
  376. NewControl                        (WindowPtr                 owningWindow,
  377.                                  const Rect *            boundsRect,
  378.                                  ConstStr255Param         controlTitle,
  379.                                  Boolean                 initiallyVisible,
  380.                                  SInt16                 initialValue,
  381.                                  SInt16                 minimumValue,
  382.                                  SInt16                 maximumValue,
  383.                                  SInt16                 procID,
  384.                                  SInt32                 controlReference)                    ONEWORDINLINE(0xA954);
  385.  
  386. EXTERN_API( ControlHandle )
  387. GetNewControl                    (SInt16                 resourceID,
  388.                                  WindowPtr                 owningWindow)                        ONEWORDINLINE(0xA9BE);
  389.  
  390. EXTERN_API( void )
  391. DisposeControl                    (ControlHandle             theControl)                            ONEWORDINLINE(0xA955);
  392.  
  393. EXTERN_API( void )
  394. KillControls                    (WindowPtr                 theWindow)                            ONEWORDINLINE(0xA956);
  395.  
  396. /*
  397.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  398.       
  399.    • CONTROL SHOWING/HIDING API'S
  400.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  401. */
  402.  
  403. EXTERN_API( void )
  404. ShowControl                        (ControlHandle             theControl)                            ONEWORDINLINE(0xA957);
  405.  
  406. EXTERN_API( void )
  407. HideControl                        (ControlHandle             theControl)                            ONEWORDINLINE(0xA958);
  408.  
  409. /*
  410.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  411.       
  412.    • CONTROL DRAWING API'S
  413.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  414. */
  415.  
  416. EXTERN_API( void )
  417. DrawControls                    (WindowPtr                 theWindow)                            ONEWORDINLINE(0xA969);
  418.  
  419. EXTERN_API( void )
  420. Draw1Control                    (ControlHandle             theControl)                            ONEWORDINLINE(0xA96D);
  421.  
  422. #define DrawOneControl(theControl) Draw1Control(theControl)
  423.  
  424. EXTERN_API( void )
  425. UpdateControls                    (WindowPtr                 theWindow,
  426.                                  RgnHandle                 updateRegion)                        ONEWORDINLINE(0xA953);
  427.  
  428. /*
  429.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  430.       
  431.    • CONTROL HIGHLIGHT API'S
  432.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  433. */
  434.  
  435. EXTERN_API( void )
  436. HiliteControl                    (ControlHandle             theControl,
  437.                                  ControlPartCode         hiliteState)                        ONEWORDINLINE(0xA95D);
  438.  
  439. /*
  440.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  441.       
  442.    • CONTROL TRACKING/DRAGGING API'S
  443.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  444. */
  445.  
  446. /*
  447.       When using the TrackControl() call when tracking an indicator, the actionProc parameter (type ControlActionUPP) 
  448.     should be replaced by a parameter of type DragGrayRgnUPP (see Quickdraw.h).
  449. */
  450. EXTERN_API( ControlPartCode )
  451. TrackControl                    (ControlHandle             theControl,
  452.                                  Point                     startPoint,
  453.                                  ControlActionUPP         actionProc)                            ONEWORDINLINE(0xA968);
  454.  
  455. EXTERN_API( void )
  456. DragControl                        (ControlHandle             theControl,
  457.                                  Point                     startPoint,
  458.                                  const Rect *            limitRect,
  459.                                  const Rect *            slopRect,
  460.                                  DragConstraint         axis)                                ONEWORDINLINE(0xA967);
  461.  
  462. EXTERN_API( ControlPartCode )
  463. TestControl                        (ControlHandle             theControl,
  464.                                  Point                     testPoint)                            ONEWORDINLINE(0xA966);
  465.  
  466. EXTERN_API( ControlPartCode )
  467. FindControl                        (Point                     testPoint,
  468.                                  WindowPtr                 theWindow,
  469.                                  ControlHandle *        theControl)                            ONEWORDINLINE(0xA96C);
  470.  
  471. /*
  472.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  473.       
  474.    • CONTROL MOVING/SIZING API'S
  475.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  476. */
  477.  
  478. EXTERN_API( void )
  479. MoveControl                        (ControlHandle             theControl,
  480.                                  SInt16                 h,
  481.                                  SInt16                 v)                                    ONEWORDINLINE(0xA959);
  482.  
  483. EXTERN_API( void )
  484. SizeControl                        (ControlHandle             theControl,
  485.                                  SInt16                 w,
  486.                                  SInt16                 h)                                    ONEWORDINLINE(0xA95C);
  487.  
  488. /*
  489.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  490.       
  491.    • CONTROL TITLE API'S
  492.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  493. */
  494.  
  495. EXTERN_API( void )
  496. SetControlTitle                    (ControlHandle             theControl,
  497.                                  ConstStr255Param         title)                                ONEWORDINLINE(0xA95F);
  498.  
  499. EXTERN_API( void )
  500. GetControlTitle                    (ControlHandle             theControl,
  501.                                  Str255                 title)                                ONEWORDINLINE(0xA95E);
  502.  
  503. /*
  504.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  505.       
  506.    • CONTROL VALUE, MIMIMUM, AND MAXIMUM API'S
  507.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  508. */
  509.  
  510. EXTERN_API( SInt16 )
  511. GetControlValue                    (ControlHandle             theControl)                            ONEWORDINLINE(0xA960);
  512.  
  513. EXTERN_API( void )
  514. SetControlValue                    (ControlHandle             theControl,
  515.                                  SInt16                 newValue)                            ONEWORDINLINE(0xA963);
  516.  
  517. EXTERN_API( SInt16 )
  518. GetControlMinimum                (ControlHandle             theControl)                            ONEWORDINLINE(0xA961);
  519.  
  520. EXTERN_API( void )
  521. SetControlMinimum                (ControlHandle             theControl,
  522.                                  SInt16                 newMinimum)                            ONEWORDINLINE(0xA964);
  523.  
  524. EXTERN_API( SInt16 )
  525. GetControlMaximum                (ControlHandle             theControl)                            ONEWORDINLINE(0xA962);
  526.  
  527. EXTERN_API( void )
  528. SetControlMaximum                (ControlHandle             theControl,
  529.                                  SInt16                 newMaximum)                            ONEWORDINLINE(0xA965);
  530.  
  531. /*
  532.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  533.       
  534.    • CONTROL VARIANT AND WINDOW INFORMATION API'S
  535.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  536. */
  537.  
  538. EXTERN_API( ControlVariant )
  539. GetControlVariant                (ControlHandle             theControl)                            ONEWORDINLINE(0xA809);
  540.  
  541. /*
  542.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  543.       
  544.    • CONTROL ACTION PROC API'S
  545.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  546. */
  547.  
  548. EXTERN_API( void )
  549. SetControlAction                (ControlHandle             theControl,
  550.                                  ControlActionUPP         actionProc)                            ONEWORDINLINE(0xA96B);
  551.  
  552. EXTERN_API( ControlActionUPP )
  553. GetControlAction                (ControlHandle             theControl)                            ONEWORDINLINE(0xA96A);
  554.  
  555. /*
  556.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  557.       
  558.    • CONTROL ACCESSOR API'S
  559.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  560. */
  561.  
  562. EXTERN_API( void )
  563. SetControlReference                (ControlHandle             theControl,
  564.                                  SInt32                 data)                                ONEWORDINLINE(0xA95B);
  565.  
  566. EXTERN_API( SInt32 )
  567. GetControlReference                (ControlHandle             theControl)                            ONEWORDINLINE(0xA95A);
  568.  
  569. EXTERN_API( Boolean )
  570. GetAuxiliaryControlRecord        (ControlHandle             theControl,
  571.                                  AuxCtlHandle *            acHndl)                                ONEWORDINLINE(0xAA44);
  572.  
  573. EXTERN_API( void )
  574. SetControlColor                    (ControlHandle             theControl,
  575.                                  CCTabHandle             newColorTable)                        ONEWORDINLINE(0xAA43);
  576.  
  577. #define GetControlListFromWindow(theWindow)        ( *(ControlHandle *) (((UInt8 *) theWindow) + sizeof(GrafPort) + 0x20))
  578. #define GetControlOwningWindowControlList(theWindow)        ( *(ControlHandle *) (((UInt8 *) theWindow) + sizeof(GrafPort) + 0x20))
  579. /*
  580.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  581.       
  582.    • VALID 'CDEF' MESSAGES
  583.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  584. */
  585.  
  586.  
  587. typedef SInt16                             ControlDefProcMessage;
  588.  
  589. enum {
  590.     drawCntl                    = 0,
  591.     testCntl                    = 1,
  592.     calcCRgns                    = 2,
  593.     initCntl                    = 3,
  594.     dispCntl                    = 4,
  595.     posCntl                        = 5,
  596.     thumbCntl                    = 6,
  597.     dragCntl                    = 7,
  598.     autoTrack                    = 8,
  599.     calcCntlRgn                    = 10,
  600.     calcThumbRgn                = 11,
  601.     drawThumbOutline            = 12
  602. };
  603.  
  604. /*
  605.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  606.       
  607.    • MAIN ENTRY POINT FOR 'CDEF'
  608.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  609. */
  610.  
  611. typedef CALLBACK_API( SInt32 , ControlDefProcPtr )(SInt16 varCode, ControlHandle theControl, ControlDefProcMessage message, SInt32 param);
  612. typedef STACK_UPP_TYPE(ControlDefProcPtr)                         ControlDefUPP;
  613. enum { uppControlDefProcInfo = 0x00003BB0 };                     /* pascal 4_bytes Func(2_bytes, 4_bytes, 2_bytes, 4_bytes) */
  614. #define NewControlDefProc(userRoutine)                             (ControlDefUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppControlDefProcInfo, GetCurrentArchitecture())
  615. #define CallControlDefProc(userRoutine, varCode, theControl, message, param)  CALL_FOUR_PARAMETER_UPP((userRoutine), uppControlDefProcInfo, (varCode), (theControl), (message), (param))
  616. #if !TARGET_OS_MAC
  617.  
  618. // Proc used to notify window that something happened to the control
  619. typedef void (*ControlNotificationProcPtr)(WindowPtr theWindow, ControlRef theControl, ControlNotification notification, long param1, long param2);
  620.  
  621. // Proc used to prefilter events before handled by control.  A client of a control calls
  622. // CTRLSetPreFilterProc() to have the control call this proc before handling the event.
  623. // If the proc returns TRUE, the control can go ahead and handle the event.
  624. typedef Boolean (*PreFilterEventProc)(ControlRef theControl, EventRecord *theEvent);
  625.  
  626. long GetControlComponentInstance(ControlRef theControl);
  627. ControlHandle GetControlHandleFromCookie(long cookie);
  628. void SetControlDefProc(short resID, ControlDefUPP proc);  
  629.  
  630. typedef ControlNotificationProcPtr ControlNotificationUPP;
  631.  
  632. #endif  /*  !TARGET_OS_MAC */
  633.  
  634. /*
  635.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  636.       
  637.    • CONSTANTS FOR DRAWCNTL MESSAGE PASSED IN PARAM
  638.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  639. */
  640.  
  641. enum {
  642.     kDrawControlEntireControl    = 0,
  643.     kDrawControlIndicatorOnly    = 129
  644. };
  645.  
  646. /*
  647.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  648.       
  649.    • CONSTANTS FOR DRAGCNTL MESSAGE PASSED IN PARAM
  650.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  651. */
  652.  
  653.  
  654. enum {
  655.     kDragControlEntireControl    = 0,
  656.     kDragControlIndicator        = 1
  657. };
  658.  
  659. /*
  660.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  661.       
  662.    • DRAG CONSTRAINT STRUCTURE PASSED IN PARAM FOR THUMBCNTL MESSAGE (IM I-332)
  663.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  664. */
  665.  
  666.  
  667. struct IndicatorDragConstraint {
  668.     Rect                             limitRect;
  669.     Rect                             slopRect;
  670.     DragConstraint                     axis;
  671. };
  672. typedef struct IndicatorDragConstraint    IndicatorDragConstraint;
  673. typedef IndicatorDragConstraint *        IndicatorDragConstraintPtr;
  674. typedef IndicatorDragConstraintPtr *    IndicatorDragConstraintHandle;
  675. #if CGLUESUPPORTED
  676. /*
  677.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  678.    • C GLUE
  679.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  680. */
  681. EXTERN_API_C( void )
  682. dragcontrol                        (ControlHandle             theControl,
  683.                                  Point *                startPt,
  684.                                  const Rect *            limitRect,
  685.                                  const Rect *            slopRect,
  686.                                  short                     axis);
  687.  
  688. EXTERN_API_C( ControlHandle )
  689. newcontrol                        (WindowPtr                 theWindow,
  690.                                  const Rect *            boundsRect,
  691.                                  const char *            title,
  692.                                  Boolean                 visible,
  693.                                  short                     value,
  694.                                  short                     min,
  695.                                  short                     max,
  696.                                  short                     procID,
  697.                                  long                     refCon);
  698.  
  699. EXTERN_API_C( short )
  700. findcontrol                        (Point *                thePoint,
  701.                                  WindowPtr                 theWindow,
  702.                                  ControlHandle *        theControl);
  703.  
  704. EXTERN_API_C( void )
  705. getcontroltitle                    (ControlHandle             theControl,
  706.                                  char *                    title);
  707.  
  708. EXTERN_API_C( void )
  709. setcontroltitle                    (ControlHandle             theControl,
  710.                                  const char *            title);
  711.  
  712. EXTERN_API_C( short )
  713. trackcontrol                    (ControlHandle             theControl,
  714.                                  Point *                thePoint,
  715.                                  ControlActionUPP         actionProc);
  716.  
  717. EXTERN_API_C( short )
  718. testcontrol                        (ControlHandle             theControl,
  719.                                  Point *                thePt);
  720.  
  721. #endif  /* CGLUESUPPORTED */
  722.  
  723. #if OLDROUTINENAMES
  724. /*
  725.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  726.    • OLDROUTINENAMES
  727.   —————————————————————————————————————————————————————————————————————————————————————————————————————————
  728. */
  729. /* Variants applicable to all controls (at least ones with text)*/
  730.  
  731. enum {
  732.     useWFont                    = popupUseWFont
  733. };
  734.  
  735.  
  736. enum {
  737.     kControlCheckboxUncheckedValue = kControlCheckBoxUncheckedValue,
  738.     kControlCheckboxCheckedValue = kControlCheckBoxCheckedValue,
  739.     kControlCheckboxMixedValue    = kControlCheckBoxMixedValue
  740. };
  741.  
  742.  
  743. enum {
  744.     inLabel                        = kControlLabelPart,
  745.     inMenu                        = kControlMenuPart,
  746.     inTriangle                    = kControlTrianglePart,
  747.     inButton                    = kControlButtonPart,
  748.     inCheckBox                    = kControlCheckBoxPart,
  749.     inUpButton                    = kControlUpButtonPart,
  750.     inDownButton                = kControlDownButtonPart,
  751.     inPageUp                    = kControlPageUpPart,
  752.     inPageDown                    = kControlPageDownPart,
  753.     inThumb                        = kControlIndicatorPart
  754. };
  755.  
  756.  
  757. enum {
  758.     kNoHiliteControlPart        = kControlNoPart,
  759.     kInLabelControlPart            = kControlLabelPart,
  760.     kInMenuControlPart            = kControlMenuPart,
  761.     kInTriangleControlPart        = kControlTrianglePart,
  762.     kInButtonControlPart        = kControlButtonPart,
  763.     kInCheckBoxControlPart        = kControlCheckBoxPart,
  764.     kInUpButtonControlPart        = kControlUpButtonPart,
  765.     kInDownButtonControlPart    = kControlDownButtonPart,
  766.     kInPageUpControlPart        = kControlPageUpPart,
  767.     kInPageDownControlPart        = kControlPageDownPart,
  768.     kInIndicatorControlPart        = kControlIndicatorPart,
  769.     kReservedControlPart        = kControlDisabledPart,
  770.     kControlInactiveControlPart    = kControlInactivePart
  771. };
  772.  
  773. #define SetCTitle(theControl, title) SetControlTitle(theControl, title)
  774. #define GetCTitle(theControl, title) GetControlTitle(theControl, title)
  775. #define UpdtControl(theWindow, updateRgn) UpdateControls(theWindow, updateRgn)
  776. #define SetCtlValue(theControl, theValue) SetControlValue(theControl, theValue)
  777. #define GetCtlValue(theControl) GetControlValue(theControl)
  778. #define SetCtlMin(theControl, minValue) SetControlMinimum(theControl, minValue)
  779. #define GetCtlMin(theControl) GetControlMinimum(theControl)
  780. #define SetCtlMax(theControl, maxValue) SetControlMaximum(theControl, maxValue)
  781. #define GetCtlMax(theControl) GetControlMaximum(theControl)
  782. #define GetAuxCtl(theControl, acHndl) GetAuxiliaryControlRecord(theControl, acHndl)
  783. #define SetCRefCon(theControl, data) SetControlReference(theControl, data)
  784. #define GetCRefCon(theControl) GetControlReference(theControl)
  785. #define SetCtlAction(theControl, actionProc) SetControlAction(theControl, actionProc)
  786. #define GetCtlAction(theControl) GetControlAction(theControl)
  787. #define SetCtlColor(theControl, newColorTable) SetControlColor(theControl, newColorTable)
  788. #define GetCVariant(theControl) GetControlVariant(theControl)
  789. #define getctitle(theControl, title) getcontroltitle(theControl, title)
  790. #define setctitle(theControl, title) setcontroltitle(theControl, title)
  791. #endif  /* OLDROUTINENAMES */
  792.  
  793.  
  794.  
  795. #if PRAGMA_STRUCT_ALIGN
  796.     #pragma options align=reset
  797. #elif PRAGMA_STRUCT_PACKPUSH
  798.     #pragma pack(pop)
  799. #elif PRAGMA_STRUCT_PACK
  800.     #pragma pack()
  801. #endif
  802.  
  803. #ifdef PRAGMA_IMPORT_OFF
  804. #pragma import off
  805. #elif PRAGMA_IMPORT
  806. #pragma import reset
  807. #endif
  808.  
  809. #ifdef __cplusplus
  810. }
  811. #endif
  812.  
  813. #endif /* __CONTROLS__ */
  814.  
  815.